import Mock from 'mockjs'
import { userId } from '.././user/index.js'

const Random = Mock.Random
let productPrice = Random.float(100, 2000, 2, 2)
let quantity = Random.integer(1, 5)
export let obj = {
  "status": 0,
  "data": {
    "cartProductVoList|1-5": [
      {
        "id|+1": 1,
        "userId": userId,
        "productId|+1": 1,
        "quantity": quantity,
        "productName|1": ["iphone7", "小米9", "小米MIX 3", "Redmi Note 7 Pro", "小米Play", "小米8"],
        "productSubtitle": "双十一促销",
        "productMainImage": "mainimage.jpg",
        "productPrice": productPrice,
        "productStatus": 1,
        "productTotalPrice": productPrice * quantity,
        "productStock|50-200": 86,
        "productSelected": true
      }
    ],
    "selectedAll|1": false
  }
}
Mock.mock('/api/carts', 'get', obj)
Mock.mock('/api/carts', 'post', obj)
Mock.mock('/api/carts/10', 'put', obj)
Mock.mock('/api/carts', 'delete', obj)
Mock.mock('/api/carts/selectAll', 'put', {
  "data": "success"
})
Mock.mock('/api/carts/unSelectAll', 'put', {
  "data": "success"
})
Mock.mock('/api/carts/products/sum', 'get', {
  "status": 0,
  "data|1-5": 2
})